Generating a basic map image in Earth Engine

Install ee-python

Follow the installation directions found here:

https://github.com/catherinekuhn/CloudtoStreet/blob/master/Python%20API%20directions.ipynb

Check your environment

Make sure that you are in the correct environment. To check your current environment, type the following. The environment you are in will have a star next to it.

    conda info --envs

If you are not in the ee-python environment, you can switch into it using

    source activate ee-python

Import & Authentication


In [4]:
# Import the Earth Engine Python Package into Python environment.
import ee
import ee.mapclient

# Initialize the Earth Engine object, using the authentication credentials.
ee.Initialize()

Visualize Geographic Data


In [5]:
image = ee.Image('srtm90_v4')
from IPython.display import Image
Image(url=image.getThumbUrl({'min':0, 'max': 3000}))


Out[5]:

In [2]:
# Print the information for an image asset. the 'srtm90_v4 file is a digital elevation model. 
# that is housed in Google's cloud and has an elevation value for every pixel across the whole earth 
# at a resolution of 30 meters. That is the map you see below in the static notebook. 

print(image.getInfo())

#celebrate the metadata!!


{u'bands': [{u'crs': u'EPSG:4326', u'crs_transform': [0.0008333333535119891, 0.0, -180.0, 0.0, -0.0008333333535119891, 60.0], u'id': u'elevation', u'data_type': {u'max': 32767, u'type': u'PixelType', u'precision': u'int', u'min': -32768}, u'dimensions': [432000, 144000]}], u'version': 1427492341199000, u'type': u'Image', u'id': u'srtm90_v4', u'properties': {u'system:time_end': 951177600000, u'system:time_start': 950227200000}}

Try it with mapclient


In [3]:
"""Display an image given its ID."""

image = ee.Image('srtm90_v4')
ee.mapclient.addToMap(image, {'min': 0, 'max': 3000})
ee.mapclient.centerMap(-91.1646, 43.8438, 10)


---------------------------------------------------------------------------
EEException                               Traceback (most recent call last)
<ipython-input-3-bf630329b3b2> in <module>()
      1 """Display an image given its ID."""
      2 
----> 3 image = ee.Image('srtm90_v4')
      4 ee.mapclient.addToMap(image, {'min': 0, 'max': 3000})
      5 ee.mapclient.centerMap(-91.1646, 43.8438, 10)

/Users/catherinekuhn/miniconda2/envs/ee-python/lib/python2.7/site-packages/ee/computedobject.pyc in __call__(cls, *args, **kwargs)
     47         return args[0]
     48       else:
---> 49         return type.__call__(cls, *args, **kwargs)
     50 
     51   def __init__(self, func, args, opt_varName=None):

/Users/catherinekuhn/miniconda2/envs/ee-python/lib/python2.7/site-packages/ee/image.pyc in __init__(self, args, version)
     47     """
     48 
---> 49     self.initialize()
     50 
     51     if version is not None:

/Users/catherinekuhn/miniconda2/envs/ee-python/lib/python2.7/site-packages/ee/image.pyc in initialize(cls)
     93     """Imports API functions to this class."""
     94     if not cls._initialized:
---> 95       apifunction.ApiFunction.importApi(cls, 'Image', 'Image')
     96       apifunction.ApiFunction.importApi(cls, 'Window', 'Image', 'focal_')
     97       cls._initialized = True

/Users/catherinekuhn/miniconda2/envs/ee-python/lib/python2.7/site-packages/ee/apifunction.pyc in importApi(cls, target, prefix, type_name, opt_prepend)
    172           added functions.
    173     """
--> 174     cls.initialize()
    175     prepend = opt_prepend or ''
    176     for name, api_func in cls._api.iteritems():

/Users/catherinekuhn/miniconda2/envs/ee-python/lib/python2.7/site-packages/ee/apifunction.pyc in initialize(cls)
    143     """Initializes the list of signatures from the Earth Engine front-end."""
    144     if not cls._api:
--> 145       signatures = data.getAlgorithms()
    146       api = {}
    147       for name, sig in signatures.iteritems():

/Users/catherinekuhn/miniconda2/envs/ee-python/lib/python2.7/site-packages/ee/data.pyc in getAlgorithms()
    379                 is not specified.
    380   """
--> 381   return send_('/algorithms', {}, 'GET')
    382 
    383 

/Users/catherinekuhn/miniconda2/envs/ee-python/lib/python2.7/site-packages/ee/data.pyc in send_(path, params, opt_method, opt_raw)
    678     # error above rather than this generic one.
    679     raise ee_exception.EEException('Server returned HTTP code: %d' %
--> 680                                    response.status)
    681 
    682   # Now known not to be an error response...

EEException: Server returned HTTP code: 404